
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ServeStaticModule } from '@nestjs/serve-static';
import { TypeOrmModule } from '@nestjs/typeorm';
import { join, resolve } from 'path';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AuthModule } from './auth/auth.module';
import { OmModule } from './om/om.module';
import { PmModule } from './pm/pm.module';
import { UmModule } from './um/um.module';
import { UploadModule } from './upload/upload.module';
const isProd = process.env.NODE_ENV == 'production';
@Module({
  imports: [
    ServeStaticModule.forRoot({
      rootPath: join(__dirname, 'static'),
    }),
    ConfigModule.forRoot({
      isGlobal: true,
      envFilePath: [isProd ? resolve('.env.prod') : resolve('.env.dev')],
    }),
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: process.env.DB_HOST,
      port: parseInt(process.env.DB_PORT), // 端口号
      username: process.env.DB_USER, // 用户名
      password: process.env.DB_PASSWD, // 密码
      autoLoadEntities: true, //自动加载实体
      synchronize: true, //是否自动同步实体文件,生产环境建议关闭
      database: process.env.DB_DATABASE, //数据库名
    }),
    
    UploadModule,
    AuthModule,
    OmModule,
    PmModule,
    UmModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
